{extend name='public/window' /}

{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label">相关图片 *</label>
                <div style="display:flex;align-items: center;padding-top: 10px;flex-wrap: wrap">
                    <div style="margin-right: 10px">
                        <div style="text-align: center;width: 200px">身份证正面</div>
                        <img src="{$list['idcard_zheng']}"  onclick="previewImg(this)" alt="" style="display: inline-block;width:300px;height: 200px">
                    </div>
                    <div style="margin-right: 10px">
                        <div style="text-align: center;width: 200px">身份证反面</div>
                        <img src="{$list['idcard_fan']}"  onclick="previewImg(this)" alt="" style="display: inline-block;width:300px;height: 200px">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['element', 'form', 'table', 'jquery', 'lucky', 'laydate', 'xmSelect', 'layedit'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var lucky = layui.lucky;
        var layedit = layui.layedit;
        var id_lists = [];
        laydate.render({
            elem: '#send_time',
            type: 'datetime',
            trigger: 'click',
            min: minDate()
        });
        layedit.set({	//设置图片接口
            uploadImage: {
                url: "{:url('Common/UpEditorPic')}", //接口url
                type: 'post'
            }
        });
        //创建一个编辑器，lay_edit为textarea标签的id值
        var index = layedit.build('content', {
            width: 200,
            height: 350    //设置编辑器的高度
        });
        //赋值
        form.verify({
            content: function(value) {
                return layedit.sync(index);
            }
        });
        form.on('select(type)', function (data) {
            var type = data.value;
            if (type == 2) {
                $(".send").css('display', 'block');
            } else {
                $(".send").css('display', 'none');
            }
        });
        var costType = [];
        var student_table = table.render({
            id: 'student_table',
            elem: '#student_table',
            page: true, //开启分页
            limit: 20,
            limits: [20, 50, 100],
            title: '标题',
            cols: [[
                {title: '', type: 'checkbox', fixed: true},
                // {title: 'id', field: 'id', width: 60},
                {title: '商户编号', field: 'merchant_sn'},
                {title: '商户名', field: 'name'},
                {title: '实际用量', field: 'useWater'},
                {title: '合计(元)', field: 'money'},
                {title: '账期', field: 'dataTime'},
            ]]
        });
        form.on('submit(add)', function (data) {
            var datas  = layui.table.cache["student_table"]
            data.field.type = 2 // 添加type
            data.field.pay_status = 0 // 支付状态
            data.field.datas = datas // 添加type
            lucky.FormSubmit("{:url('add')}",data.field,true);
            return false;
        });
    })
    function minDate() {
        var now = new Date();
        return now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate();
    }

</script>

{/block}

